<script lang="ts" setup>
  import { reactive } from 'vue';
  import {
    MailOutlined,
    CalendarOutlined,
    AppstoreOutlined,
    SettingOutlined,
  } from '@ant-design/icons-vue';
  import Switch from '@sscd/switch';
  import type { MenuMode, MenuTheme } from '@sscd/menu';
  import Menu from '@sscd/menu';
  const state = reactive({
    mode: 'inline' as MenuMode,
    theme: 'light' as MenuTheme,
    selectedKeys: ['1'],
    openKeys: ['sub1'],
  });
  const changeMode = (checked: boolean) => {
    state.mode = checked ? 'vertical' : 'inline';
  };
  const changeTheme = (checked: boolean) => {
    state.theme = checked ? 'dark' : 'light';
  };
</script>

<template>
  <div class="demo">
    <div class="demo-title">切换菜单类型</div>
    <div class="demo-content">
      <Switch :checked="state.mode === 'vertical'" @change="changeMode" />
      Change Mode
      <span class="ant-divider" style="margin: 0 1em" />
      <Switch :checked="state.theme === 'dark'" @change="changeTheme" />
      Change Theme
      <br />
      <br />
      <Menu
        v-model:openKeys="state.openKeys"
        v-model:selectedKeys="state.selectedKeys"
        style="width: 256px"
        :mode="state.mode"
        :theme="state.theme"
      >
        <Menu.Item key="1">
          <template #icon>
            <MailOutlined />
          </template>
          Navigation One
        </Menu.Item>
        <Menu.Item key="2">
          <template #icon>
            <CalendarOutlined />
          </template>
          Navigation Two
        </Menu.Item>
        <Menu.SubMenu key="sub1">
          <template #icon>
            <AppstoreOutlined />
          </template>
          <template #title>Navigation Three</template>
          <Menu.Item key="3">Option 3</Menu.Item>
          <Menu.Item key="4">Option 4</Menu.Item>
          <Menu.SubMenu key="sub1-2" title="Submenu">
            <Menu.Item key="5">Option 5</Menu.Item>
            <Menu.Item key="6">Option 6</Menu.Item>
          </Menu.SubMenu>
        </Menu.SubMenu>
        <Menu.SubMenu key="sub2">
          <template #icon>
            <SettingOutlined />
          </template>
          <template #title>Navigation Four</template>
          <Menu.Item key="7">Option 7</Menu.Item>
          <Menu.Item key="8">Option 8</Menu.Item>
          <Menu.Item key="9">Option 9</Menu.Item>
          <Menu.Item key="10">Option 10</Menu.Item>
        </Menu.SubMenu>
      </Menu>
    </div>
  </div>
</template>
